/* UTF8 Encoding */
/*-----------------------------------------------------------------------
|                            FILE DESCRIPTION                           |
-----------------------------------------------------------------------*/
/*----------------------------------------------------------------------
  - File name     : bsp_flash_config.h
  - Author        : liuzhihua (liuzhihuawy@163.com)
  - Update date   : 2024.06.08
  - Brief         : board flash config
  - Version       : v0.1
-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------
|                               UPDATE NOTE                             |
-----------------------------------------------------------------------*/
/**
 * Update note:
 * ------------   ---------------   ----------------------------------
 *     Date            Author                      Note
 * ------------   ---------------   ----------------------------------
 *  2024.06.08       liuzhihua                 Create file
 ***/

#ifndef __BSP_FLASH_CONFIG_H__
#define __BSP_FLASH_CONFIG_H__
/*-----------------------------------------------------------------------
|                               INCLUDES                                |
-----------------------------------------------------------------------*/
#include "stm32_flash.h"
#ifdef __cplusplus
extern "C"
{
#endif
  /*-----------------------------------------------------------------------
  |                                DEFINES                                |
  -----------------------------------------------------------------------*/
  /* Flash的最大页数见STM32参考手册 Flash module organization */
  #define BSP_FLASH_MAX_PAGE      32  // Flash最大页数
  #define BSP_FLASH_CFGSAVE_PAGE  31  // 保存配置参数使用的页数索引[0,max-1]

  #if (BSP_FLASH_CFGSAVE_PAGE > BSP_FLASH_MAX_PAGE - 1)
  #error "BSP_FLASH_CFGSAVE_PAGE must be less than BSP_FLASH_MAX_PAGE - 1"
  #endif

  //    配置参数控制结构体
  typedef struct __BSP_ConfigInfoTypeDef
  {
    uint32_t crc32;             //  CRC校验值
    uint32_t powerOnCount;    //  开机次数
    /* 用户添加存储到Flash的参数 */

  } BSP_ConfigInfoTypeDef;



  /*-----------------------------------------------------------------------
  |                                  API                                  |
  -----------------------------------------------------------------------*/
  //      系统配置信息
  extern BSP_ConfigInfoTypeDef systemConfigInfo;

  void bsp_flash_config_init(void);
  void bsp_flash_config_save(const void *arg);
  void bsp_flash_config_save_start(void);


#ifdef __cplusplus
}
#endif
#endif
